#include "a39c_t400a22d1a.h"

void A39C_T400A22D1a_Config()
{
    //配置模式，MD0=0,MD1=0，串口默认9600 8N1
    HAL_GPIO_WritePin(AS_MD0_GPIO_Port, AS_MD0_Pin, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(AS_MD1_GPIO_Port, AS_MD1_Pin, GPIO_PIN_RESET);
    HAL_Delay(100);
    
    UART_Set_BoundRate(&huart2, 9600);

    /*透明传输 115200 8N1 无前导唤醒码 空速62.5k 打包长度64Bytes*/   
    const uint8_t config_data[64] = {0x80, 0x04, 0x1E, 0x00, 0x01, 0xC2, 0x00, 0x00, 0x02, 
        0xFF, 0x00, 0x01, 0x05, 0x03, 0xE8, 0x00, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x73, 
        0x68, 0x69, 0x6E, 0x69, 0x6E, 0x67, 0x2E, 0x63, 0x6F, 0x6D, 0x7C, 0x7C, 0x7C, 
        0x7C, 0x7C, 0x05, 0x40, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x00, 0x0A, 
        0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x02};
    
    HAL_UART_Transmit(&huart2, config_data, 61, 1000);
    HAL_Delay(100);

    UART_Set_BoundRate(&huart2, 115200);
}

void A39C_T400A22D1a_Init()
{
    //一般工作模式，MD0=1,MD1=0
    HAL_GPIO_WritePin(AS_MD0_GPIO_Port, AS_MD0_Pin, GPIO_PIN_SET);
    HAL_GPIO_WritePin(AS_MD1_GPIO_Port, AS_MD1_Pin, GPIO_PIN_RESET);
    HAL_Delay(100);
    HAL_UART_Transmit(&huart2, (uint8_t*)"System Boot\r\n", 14, 1000);
}